Out of sequence

The Haskell language provides the list type ([a]) for values that correspond to a finite sequence of values of the same type (a). Other packages export other types that do the same: containers exports Seq a and vector exports Vector a from module Data.Vector and other types from other modules. The values of the different types have different underlying representations and have different performance for similar operations.

I wanted to convert efficiently from a Vector a value to a Seq a value and back again, in part because the package hgeometry makes use of Seq a in the representation of polygonal lines.

IsList

Seq a and Vector a each provide instances of typeclass IsList, which provides functions toList and fromList. However, converting via a list using fromList . toList was unlikely to be efficient.

fromFunction

Module Data.Sequence exports fromFunction :: Int -> (Int -> a) -> Seq a and indexing is fast for values of type Vector a. So, I had:

vector-builder package

Seq provides an instance of typeclass Foldable and package vector-builder exports two functions:

build :: Data.Vector.Generic.Vector v a => Builder a -> v a

foldable :: Foldable f => f a -> Builder a

So, I had: